import { mAxios, encodeURL } from "./axios.js";
import { useUserStore } from "~/utils/pinia/user.js"
const userStore = useUserStore()

// 新发现工业卫士表格数据 
const getNewguardTable = (params) => {
    return mAxios.get('guard/device/tmp/get',{params: encodeURL(params)})
}
// 新发现工业卫士表格数量
const getNewguardCount = (params) => {
    return mAxios.get('guard/device/tmp/getCount')
}
// 新发现工业卫士加入拓扑
const setAddTopology = (oid) => {
    return mAxios.post(`guard/device/topology/${userStore.domains.domainInfo.currentTopologyId}/${oid}`)
}
// 新发现工业卫士删除
const setDelNewDefender = (oid) => {
    return mAxios.post(`guard/device/tmp/delete/${userStore.domains.domainInfo.currentTopologyId}/${oid}`)
}
// 已安装工业卫士表格数据 
const getInstallguardTable = (params) => {
    return mAxios.get('guardManager/list',{params: encodeURL(params)})
}
// 已安装工业卫士表格数量
const getInstallguardCount = (params) => {
    return mAxios.get('guardManager/count',{params: encodeURL(params)})
}
// 已安装工业卫士部门/自定义分组列表
const getInstallAsyncTree = (id) => {
    return mAxios.get(`guardManager/asyncTree?categoryId=1&hasdevice=true&id=${id}`)
}
// 已安装工业卫士修改名称
const getInstallGuardChangeName = (oid, name) => {
    return mAxios.post(`guard/changeName/${oid}/${name}`)
}
// 已安装卫士 删除
const setBatchDelete = (oid) => {
    return mAxios.post(`guardManager/device/batchDelete/${userStore.domains.domainInfo.currentTopologyId}/oids?oids=${oid}`)
}
const setBatchScan = (oid) => {
    return mAxios.post(`guardManager/batchScan/oids?oids=${oid}`)
}
const setBatchMode = (params) => {
    return mAxios.post(`guardManager/batchMode/oids`, params)
}
// 已安装卫士查看->基本信息
const getInfoDetail = (params) => {
    return mAxios.get(`guard/device/detail/${params}`)
}
// 已安装卫士查看->syslog日志表格数据
const getGuardLogs = (params) => {
    return mAxios.get('guard/guardLogs/get',{params: encodeURL(params)})
}
// 已安装卫士查看->syslog日志表格数据的数量
const getGetGuardLogsCount = (params) => {
    return mAxios.get('guard/guardLogs/getGuardLogsCount',{params: encodeURL(params)})
}
// 已安装卫士查看->应用程序白名单表格数据
const getGuardAppWhiteList = (params) => {
    return mAxios.get('guard/guardAppWhiteList/get',{params: encodeURL(params)})
}
// 已安装卫士查看->应用程序白名单表格数据的数量
const getGuardAppWhiteCount = (params) => {
    return mAxios.get('guard/guardAppWhiteList/getCount',{params: encodeURL(params)})
}
// 已安装卫士查看->应用程序白名单表格数据的数量
const getGuardAppWhiteSync = (params) => {
    return mAxios.post(`guard/guardWhitelist/${params}/sync`)
}
// 已安装卫士查看->外设表格数据
const getGuardPeripheral = (params) => {
    return mAxios.get('guard/guardPeripheral/get',{params: encodeURL(params)})
}
// 已安装卫士查看->外设表格数据的数量
const getGuardPeripheralCount = (params) => {
    return mAxios.get('guard/guardPeripheral/getGuardPeripheralCount',{params: encodeURL(params)})
}
// 已安装卫士查看->外设表格数据的数量
const getGuardPeripheralSync = (params) => {
    return mAxios.post(`guard/guardPeripheral/${params}/sync`)
}
// 已安装卫士部门/自定义分组 查询分组名称是否存在
const getGuardCategoryCheckName = (params) => {
    return mAxios.get('category/checkName',{params: encodeURL(params)})
}
// 已安装卫士部门/自定义分组 添加分组
const getGuardCategoryAdd = (params) => {
    return mAxios.post(`guardManager/category/add?id=${params.id}&name=${params.name}&category=${params.category}`)
}
// 已安装卫士部门/自定义分组 修改分组名
const getGuardCategoryUpdate = (params) => {
    return mAxios.post(`guardManager/category/update?id=${params.id}&name=${params.name}&category=${params.category}`)
}
// 已安装卫士部门/自定义分组 删除分组
const getGuardCategoryDelete = (params) => {
    return mAxios.post(`guardManager/category/delete?id=${params}`)
}
// 已安装卫士部门/自定义分组 修改部门
const setUpdateGuardCategory = (params) => {
    return mAxios.post(`guardManager/updateGuardCategory`,params)
}

// 获取授权
const getAuth = (params) => {
    return mAxios.get(`guardManager/guard/getAuth/${params}`)
}
// 授权
const setAuth = (params) => {
    return mAxios.post(`guardManager/guard/setAuth`,params)
}
// 补全登记信息
const getResources = (params) => {
    return mAxios.post(`guardManager/guard/resources`,params)
}
// 修改终端模式
const setMode = (params) => {
    return mAxios.post(`guardManager/guard/mode/${params.oid}/${params.type}`)
}
// 开始扫描
const setStartScan = (oid, params) => {
    return mAxios.post(`guardManager/guard/scan/${oid}`, params)
}
// 停止扫描
const setStopScan = (oid, param) => {
    return mAxios.post(`guardManager/guard/stopScan/${oid}`, param)
}
// 编辑终端信息
const setInfo = (params) => {
    return mAxios.put(`guardManager/info`,params)
}
export {
    getNewguardTable,
    getNewguardCount,
    setAddTopology,
    setDelNewDefender,
    getInstallguardTable,
    getInstallguardCount,
    getInstallGuardChangeName,
    getInfoDetail,
    getGuardLogs,
    getGetGuardLogsCount,
    setBatchDelete,
    getGuardAppWhiteList,
    getGuardAppWhiteCount,
    getGuardAppWhiteSync,
    getGuardPeripheral,
    getGuardPeripheralCount,
    getGuardPeripheralSync,
    getInstallAsyncTree,
    getGuardCategoryCheckName,
    getGuardCategoryAdd,
    getGuardCategoryUpdate,
    getGuardCategoryDelete,
    setUpdateGuardCategory,
    getResources,
    setMode,
    setStartScan,
    setBatchScan,
    setBatchMode,
    setStopScan,
    setInfo,
    getAuth,
    setAuth
}